<template>
  <div class="settings-page">
    <div class="page-header">
      <h1 class="stagger-item">设置</h1>
      <p class="page-description stagger-item">管理您的应用偏好和配置</p>
    </div>
    
    <div class="settings-sections">
      <div class="settings-section stagger-item">
        <h2>外观设置</h2>
        <div class="setting-item">
          <label class="setting-label">主题模式</label>
          <div class="setting-control">
            <select v-model="theme" class="setting-select">
              <option value="light">浅色模式</option>
              <option value="dark">深色模式</option>
              <option value="auto">跟随系统</option>
            </select>
          </div>
        </div>
        
        <div class="setting-item">
          <label class="setting-label">语言</label>
          <div class="setting-control">
            <select v-model="language" class="setting-select">
              <option value="zh-CN">简体中文</option>
              <option value="en-US">English</option>
            </select>
          </div>
        </div>
      </div>
      
      <div class="settings-section stagger-item">
        <h2>通知设置</h2>
        <div class="setting-item">
          <label class="setting-label">邮件通知</label>
          <div class="setting-control">
            <label class="toggle-switch">
              <input type="checkbox" v-model="emailNotifications">
              <span class="toggle-slider"></span>
            </label>
          </div>
        </div>
        
        <div class="setting-item">
          <label class="setting-label">推送通知</label>
          <div class="setting-control">
            <label class="toggle-switch">
              <input type="checkbox" v-model="pushNotifications">
              <span class="toggle-slider"></span>
            </label>
          </div>
        </div>
      </div>
      
      <div class="settings-section stagger-item">
        <h2>数据管理</h2>
        <div class="setting-item">
          <label class="setting-label">自动备份</label>
          <div class="setting-control">
            <select v-model="backupFrequency" class="setting-select">
              <option value="daily">每日</option>
              <option value="weekly">每周</option>
              <option value="monthly">每月</option>
              <option value="never">从不</option>
            </select>
          </div>
        </div>
        
        <div class="setting-actions">
          <button class="btn btn-primary" @click="saveSettings">保存设置</button>
          <button class="btn btn-secondary" @click="resetSettings">恢复默认</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const theme = ref('light')
const language = ref('zh-CN')
const emailNotifications = ref(true)
const pushNotifications = ref(false)
const backupFrequency = ref('weekly')

const saveSettings = () => {
  // 保存设置逻辑
  alert('设置已保存！')
}

const resetSettings = () => {
  theme.value = 'light'
  language.value = 'zh-CN'
  emailNotifications.value = true
  pushNotifications.value = false
  backupFrequency.value = 'weekly'
  alert('设置已恢复默认值！')
}
</script>

<style scoped>
.settings-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  min-height: 100vh;
}

.page-header {
  text-align: center;
  margin-bottom: 50px;
}

.page-header h1 {
  font-size: 2.2rem;
  color: #1e293b;
  margin-bottom: 10px;
}

.page-description {
  font-size: 1.1rem;
  color: #64748b;
}

.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.settings-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.settings-section h2 {
  font-size: 1.5rem;
  color: #2c3e50;
  margin-bottom: 25px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e9ecef;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding: 15px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.setting-label {
  font-weight: 600;
  color: #495057;
  font-size: 1rem;
}

.setting-control {
  display: flex;
  align-items: center;
}

.setting-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 150px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #3498db;
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

.setting-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 30px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

@media (max-width: 768px) {
  .settings-page {
    padding: 15px;
  }
  
  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .setting-control {
    width: 100%;
    justify-content: flex-end;
  }
  
  .setting-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
}
</style>